package com.weme.chat.viewmode

import com.weme.common.base.BaseViewModel
import com.weme.common.network.NetWorkUrl
import com.weme.common.util.LiveConfig.NET_WORK_CHAT
import dev.kratos.api.im_server.v1.AfterSendImMsgRequest
import dev.kratos.api.im_server.v1.TranslateRequest
import dev.kratos.api.user_server.v1.*
import io.agora.chat.ChatClient
import io.agora.chat.Conversation

class ChatViewMode:BaseViewModel() {
    var conversationId: String = ""
    var userName = ""
    var conversation: Conversation? = null
    fun initConversation(){
        conversation = ChatClient.getInstance().chatManager().getConversation(conversationId)
    }

    fun  getAlubm(req: GetAlbumRequest){
        sendNetworkRequest(req.toByteArray(),
            NetWorkUrl.GetChatAlbum )
    }

    fun sendGift(req:SendGiftRequest) {
        sendNetworkRequest(req.toByteArray(),
            NetWorkUrl.SendChatGift )
    }


    fun getChatUserInfo(req: GetUserInfoRequest){
        sendNetworkRequest(req.toByteArray(),
            NetWorkUrl.ChatUserInfo )

    }

    fun  setBlock(req: BlackRequest){
        sendNetworkRequest(req.toByteArray(),
            NetWorkUrl.Black )
    }

    fun  setUnBlock(req: UnBlackRequest){
        sendNetworkRequest(req.toByteArray(),
            NetWorkUrl.UnBlack )
    }

    fun  setReport(req: ReportRequest){
        sendNetworkRequest(req.toByteArray(),
            NetWorkUrl.Report )
    }

    fun  afterSendImMsg(req: AfterSendImMsgRequest){
        sendImNetworkRequest(req.toByteArray(),
            NetWorkUrl.AfterSendImMsg )
    }

    fun setTranslate(msg:String,targetLang:String){
        sendImNetworkRequest(TranslateRequest.newBuilder().addContent(msg).setTargetLang(targetLang).build().toByteArray(),NetWorkUrl.Translate)
    }
}